package Test;

import java.util.*;

/**
 * @author Kevin
 * @date 2020/4/5 10:57
 * 最长子序列
 */
public class Main1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        List<Integer> list1 = new ArrayList();
        //分别得到两侧砍去树的编号集合
        for(int i = 0; i < num; i++) {
            int temp = sc.nextInt();
            list1.add(temp);
        }
        int[] dp = new int[num];
        Arrays.fill(dp, 1);
        for (int i = 1; i < num; i++){

            for (int j = i-1; j >= 0; j--) {
                if (list1.get(i) > list1.get(j)) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
        }
        System.out.println(num - dp[num-1]);



    }
}
